<template>
  <view class="goods-item" @click="gotoDetail(goods)">
    
    <view class="goods-item-image">
      <image :src="goods.goods_small_logo || defaultPic"></image>
    </view>
    
    <view class="goods-item-desc">
      <text class="goods-item-title">{{goods.goods_name}}</text>
      <text class="goods-item-price">￥ {{goods.goods_price | toFixed}}</text>
    </view>
    
  </view>
</template>

<script>
  export default {
    name:"my-goods",
    props:{
      goods:{
        type: Object,
        default: () => {}
      }
    },
    data() {
      return {
        
        // 默认图片地址
        defaultPic:''
      };
    },
    methods:{
      gotoDetail(){
        this.$emit('click',this.goods)
      }
    },
    filters:{
      toFixed(num){
        return Number(num).toFixed(2)
      }
    }
  }
</script>

<style lang="scss">

  .goods-item {
    display: flex;
    border-bottom: 1px solid #FDFDFD;
    padding: 10px 5px;
    
    
    .goods-item-image {
      image {
        width: 100px;
        height: 100px;
        padding: 0 6px;
      }
    }
    .goods-item-desc {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .goods-item-title{
        font-size: 13px;
      }
      .goods-item-price{
        font-size: 16px;
        color: #C00000;
      }
    }
  }
</style>